import requests
import json

user_input='我是一名正在备战考研的大三学生，现在感觉压力很大'

url = "http://372887w3y9.zicp.fun/api/chat"
prompt = f"""
        {user_input}
        请以专业心理咨询师的身份用中文给出回复
        """
data = {
            'model': 'deepseek-r1:1.5b',
            "messages": [
                {
                    "role": "user",
                    "content": prompt
                }
            ],
            "options": {
                "num_ctx": 512,
                "raw": True  # 跳过思考过程
            },
            "stream": False  # 获取完整响应
        }
print("开始")
response = requests.post(
    "http://127.0.0.1:11435/api/chat",
    json=data
)

if response.status_code == 200:
    response_data = response.json()
    # 直接从message中提取content
    print(response_data.get('message', {}).get('content', '未收到有效回复'))
else:
    print(f"请求失败，状态码: {response.status_code}")
    print("错误详情:", response.text)